import request from '../../utils/request'
import axios from 'axios'

export const findUserList = (current, size, userVo) => {
  return axios({
    url: '/api/user/findUserPage',
    method: 'post',
    /*localhost:8080/user?id=  方式传值*/
    params: {
      current,
      size
    },
    /*json数据传值*/
    data: userVo
  })
}

/*添加用户*/
export const saveUser = (user) => {
  return axios({
    url: '/api/user/addUser',
    method: 'post',
    data: user
  })
}

/*根据id删除用户*/
export const deleteUserById = (id) => {
  return axios({
    url: '/api/user/deleteUserById',
    method: 'post',
    params: {
      id
    },
  })
}

/*根据id查询用户角色*/
export const getUserRoles = (id) => {
  return axios({
    url: '/api/user/haveRoles',
    method: 'get',
    params: {
      id
    },
  })
}

/*更新用户角色*/
export const assignRoles = (id, rids) => {
  return axios({
    url: '/api/user/assignRoles',
    method: 'post',
    params: {
      id
    },
    data: rids
  })
}

/*更新用户状态*/
export const updateStatus = (id, status) => {
  return axios({
    url: '/api/user/updateStatus',
    method: 'put',
    params: {
      id,
      status
    },
  })
}

/*根据id批量删除用户*/
export const deleteUsersByIds = (ids) => {
  return axios({
    url: '/api/user/deleteUsersByIds',
    method: 'post',
    params: {
      ids
    },
  })
}

/*根据用户名更新用户*/
export const updateUser = (user) => {
  return axios({
    url: '/api/user/updateUser',
    method: 'post',
    data: user
  })
}

/*根据用户名更新用户*/
export const updateUserPassWord = (oldPassword, newPassword) => {
  return axios({
    url: '/api/user/updateUserPassWord',
    method: 'post',
    params: {
      oldPassword,
      newPassword
    },
  })
}

/*导出用户列表*/
export const downUserExcel = () => {
  return axios({
    url: '/api/user/excel',
    method: 'post',
    responseType: 'blob'
  })
}


